package com.roger.cmdkit.cases;

import com.roger.cmdkit.base.CmdBase;
import static com.roger.cmdkit.base.CmdHelper.getNextArg;

public class BodyMassIndex implements CmdBase {
    @Override
    public void cmdS(String[] args){
        try {
            float h = Float.parseFloat(getNextArg(args,"-h"));
            float w = Float.parseFloat(getNextArg(args,"-w"));
            if (h>0 && w>0) {
                float bmi = 10000*w/h/h;
                mark(bmi);
            }else {
                System.out.println("Data error with your height or weight");
            }
        }catch (Throwable e){
            System.out.println("Cmd error");
        }
    }

    private void mark(float f){
        if(f <18.5){
            System.out.println("your body is thin");
        }else if(f <= 23.9){
            System.out.println("your body is very good");
        }else if(f <= 26.9){
            System.out.println("your body is Overweight");
        }else{
            System.out.println("your body is super fat");
        }
    }
}
